package com.woniuxy.infrastructure.controller;

import com.woniuxy.infrastructure.pojo.WcmBuilding;
import com.woniuxy.infrastructure.service.WcmBuildingService;
import com.woniuxy.infrastructure.pojo.WcmCommunity;
import com.woniuxy.infrastructure.service.WcmCommunityService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/building")
@AllArgsConstructor
@CrossOrigin
public class BuildingController {
    private final WcmBuildingService wcmBuildingService;
    private final WcmCommunityService wcmCommunityService;

    // 查询全部building
    @GetMapping("/all")
    public List<WcmBuilding> getAllBuildings() {
        return wcmBuildingService.list();
    }

    // 根据id查询building
    @GetMapping("/{id}")
    public WcmBuilding getBuildingById(@PathVariable Long id) {
        return wcmBuildingService.getById(id);
    }

    // 根据communityId查询小区信息
    @GetMapping("/community/{communityId}")
    public WcmCommunity getCommunityByCommunityId(@PathVariable Long communityId) {
        return wcmCommunityService.getById(communityId);
    }
} 